import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2;

/*
 * Search - 租户级子账户查询表单
 * @date: 2018/11/19 20:03:51

 */
import React from 'react';
import { Form, Button, Input, Col, Row, Select } from 'antd';
import { Bind } from 'lodash-decorators';
import cacheComponent from 'components/CacheComponent';
import { SEARCH_COL_CLASSNAME, SEARCH_FORM_ROW_LAYOUT, FORM_COL_4_LAYOUT, SEARCH_FORM_ITEM_LAYOUT } from 'utils/constants';
import intl from 'utils/intl';
/**
 * 租户级子账户查询表单
 * @extends {PureComponent} - React.PureComponent
 * @reactProps {Function} handleSearch  搜索
 * @reactProps {Function} handleFormReset  重置表单
 * @reactProps {Function} renderAdvancedForm 渲染所有查询条件
 * @reactProps {Function} renderSimpleForm 渲染缩略查询条件
 * @return React.element
 */

var FormItem = Form.Item; // @formatterCollections({ code: 'spfm.invitationList' })

var FilterForm = (_dec = Form.create({
  fieldNameProp: null
}), _dec2 = cacheComponent({
  cacheKey: '/ciam/sub-account-org/list'
}), _dec3 = Bind(), _dec4 = Bind(), _dec5 = Bind(), _dec6 = Bind(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_React$Component) {
  _inherits(FilterForm, _React$Component);

  var _super = _createSuper(FilterForm);

  function FilterForm(props) {
    var _this;

    _classCallCheck(this, FilterForm);

    _this = _super.call(this, props);
    props.onRef(_assertThisInitialized(_this));
    _this.state = {
      expandForm: false
    };
    return _this;
  } // 查询条件展开/收起


  _createClass(FilterForm, [{
    key: "toggleForm",
    value: function toggleForm() {
      var expandForm = this.state.expandForm;
      this.setState({
        expandForm: !expandForm
      });
    }
    /**
     * 查询
     */

  }, {
    key: "handleSearch",
    value: function handleSearch() {
      var onFilterChange = this.props.onFilterChange;

      if (onFilterChange) {
        onFilterChange();
      }
    }
    /**
     * 重置表单
     */

  }, {
    key: "handleFormReset",
    value: function handleFormReset() {
      var form = this.props.form;
      form.resetFields();
    }
    /**
     * 渲染查询条件
     * @returns React.component
     */

  }, {
    key: "renderSearchForm",
    value: function renderSearchForm() {
      var _this2 = this;

      var _this$props = this.props,
          form = _this$props.form,
          userType = _this$props.userType,
          customizeFilterForm = _this$props.customizeFilterForm;
      var expandForm = this.state.expandForm;
      return customizeFilterForm({
        code: 'CIAM.SUB_ACCOUND.FILTER',
        form: form,
        expand: expandForm
      }, /*#__PURE__*/React.createElement(Form, {
        className: "more-fields-search-form"
      }, /*#__PURE__*/React.createElement(Row, SEARCH_FORM_ROW_LAYOUT, /*#__PURE__*/React.createElement(Col, {
        span: 18
      }, /*#__PURE__*/React.createElement(Row, Object.assign({
        type: "flex",
        gutter: 24,
        align: "bottom"
      }, SEARCH_FORM_ROW_LAYOUT), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(FormItem, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.loginName').d('账号')
      }), form.getFieldDecorator('loginName')( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.userType').d('用户类型')
      }), form.getFieldDecorator('userType', {
        initialValue: 'P'
      })( /*#__PURE__*/React.createElement(Select, {
        onChange: function onChange() {
          setTimeout(function () {
            _this2.handleSearch();
          }, 0);
        }
      }, userType.map(function (item) {
        return /*#__PURE__*/React.createElement(Select.Option, {
          value: item.value,
          key: item.value
        }, item.meaning);
      }))))), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(FormItem, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.phone').d('手机号码')
      }), form.getFieldDecorator('phone')( /*#__PURE__*/React.createElement(Input, null))))), /*#__PURE__*/React.createElement(Row, Object.assign({}, SEARCH_FORM_ROW_LAYOUT, {
        style: {
          display: expandForm ? '' : 'none'
        }
      }), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(FormItem, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.email').d('邮箱')
      }), form.getFieldDecorator('email')( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(FormItem, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.realName').d('名称')
      }), form.getFieldDecorator('realName')( /*#__PURE__*/React.createElement(Input, null)))))), /*#__PURE__*/React.createElement(Col, Object.assign({}, FORM_COL_4_LAYOUT, {
        className: SEARCH_COL_CLASSNAME
      }), /*#__PURE__*/React.createElement(FormItem, null, /*#__PURE__*/React.createElement(Button, {
        style: {
          display: expandForm ? 'none' : 'inline-block'
        },
        onClick: this.toggleForm
      }, intl.get("cpaas.common.button.viewMore").d('更多查询')), /*#__PURE__*/React.createElement(Button, {
        style: {
          display: expandForm ? 'inline-block' : 'none'
        },
        onClick: this.toggleForm
      }, intl.get('cpaas.common.button.collected').d('收起查询')), /*#__PURE__*/React.createElement(Button, {
        onClick: this.handleFormReset
      }, intl.get('cpaas.common.button.reset').d('重置')), /*#__PURE__*/React.createElement(Button, {
        htmlType: "submit",
        type: "primary",
        onClick: this.handleSearch
      }, intl.get('cpaas.common.button.search').d('查询')))))));
    }
  }, {
    key: "render",
    value: function render() {
      return /*#__PURE__*/React.createElement("div", {
        className: "table-list-search"
      }, this.renderSearchForm());
    }
  }]);

  return FilterForm;
}(React.Component), (_applyDecoratedDescriptor(_class2.prototype, "toggleForm", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "toggleForm"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleSearch", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSearch"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleFormReset", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "handleFormReset"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "renderSearchForm", [_dec6], Object.getOwnPropertyDescriptor(_class2.prototype, "renderSearchForm"), _class2.prototype)), _class2)) || _class) || _class);
export { FilterForm as default };